import request from '@/router/axios';

export const getList = (current, size, offerId, params) => {
  return request({
    url: '/api/beetles-offer/creative/page',
    method: 'get',
    params: {
      ...params,
      offerId,
      current,
      size,
    }
  })
}

export const getDetail = (id) => {
  return request({
    url: '/api/beetles-offer/creative/detail',
    method: 'get',
    params: {
      id
    }
  })
}


export const shareCreative = (ids) => {
  return request({
    url: '/api/beetles-offer/creative/shareCreative',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const creativeGenWaterMark = (offerId, ids) =>{
  return request({
    url: '/api/beetles-offer/creative/genWaterMark',
    method: 'post',
    params: {
      offerId,
      ids,
    }
  })
}

export const platformCopyCreative = (ids, platforms) => {
  return request({
    url: '/api/beetles-offer/creative/platformCopyCreative',
    method: 'post',
    params: {
      ids,
      platforms,
    }
  })
}

export const remove = (ids) => {
  return request({
    url: '/api/beetles-offer/creative/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = async (data) => {
  return request({
    url: '/api/beetles-offer/creative/save',
    method: 'post',
    data: data
  })
}

//获取素材库存在的设计师
export const getDesigner = () => {
  return request({
    url: '/api/beetles-offer/creative/get-exist-designer',
    method: 'get',

  })
}

//获取设计师名单
export const getDesignerSelect = () => {
  return request({
    url: '/api/blade-user/get-designer-select',
    method: 'get'
  })
}


//获取优化师名单
export const getOptimizer = () => {
  return request({
    url: '/api/blade-user/get-optimizer-select',
    method: 'get',
  })
}

//发表评论
export const sendMessage = (data) => {
  return request({
    url: '/api/beetles-offer/creativecomment/save',
    method: 'post',
    data: data
  })
}

export const getMessageList = (current, size, params) => {
  return request({
    url: '/api/beetles-offer/creativecomment/page',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

//删除评论
export const removeMessage = (ids) => {
  return request({
    url: '/api/beetles-offer/creativecomment/remove',
    method: 'post',
    params: {
      ids
    }
  })
}

//获取提交信息
export const getInfoData = (creativeId) => {
  return request({
    url: '/api/beetles-offer/creativeaudit/get-audit-info',
    method: 'get',
    params: {
      creativeId
    }
  })
}

export const update = (data) => {
  return request({
    url: '/api/beetles-offer/creative/update',
    method: 'post',
    data: data
  })
}
//审核
export const examine = (data) => {
  return request({
    url: '/api/beetles-offer/creativeaudit/save',
    method: 'post',
    data: data
  })
}

/**
 * 获取素材版本信息
 */
export const getAllVersionInfo = (creativeId) => {
  return request({
    url: '/api/beetles-offer/creative/get-all-version-info',
    method: 'get',
    params: {creativeId: creativeId}
  })
}

/**
 * 素材禁用
 */

export const disable = (data) => {
  return request({
    url: '/api/beetles-offer/creative/creative-ban',
    method: 'post',
    data: data
  })
}
//解除禁用
export const clearDisable = (data) => {
  return request({
    url: '/api/beetles-offer/creative/creative-open',
    method: 'post',
    data: data
  })
}

// 获取便签列表
export const getTagsList = () => {
  return request({
    url: '/api/beetles-offer/creative/select/tags',
    method: 'get',
  })
}


// 上传视频到youtube
export const uploadToYoutube = (ids) => {
  return request({
    url: '/api/beetles-offer/creative/uploadToYoutube',
    method: 'get',
    params: {ids}
  })
}

export const changeLocalFilename = (name, id) => {
  return request({
    url: '/api/beetles-offer/creative/change-local-file-name',
    method: 'put',
    params: {name, id}
  })
}

export const getNewLocalFilename = (id, localFilename) => {
  return request({
    url: '/api/beetles-offer/creative/new-local-filename',
    method: 'get',
    params: {id, localFilename}
  })
}

export const updateRemark = (creativeId, remark) => {
  return request({
    url: '/api/beetles-offer/creative/update-creative-remark',
    method: 'post',
    params: {creativeId, remark}
  })
}

export const getOriginator = () => {
  return request({
    url: '/api/blade-user/select/user',
    method: 'get'
  })
}

/**
 *获取订单分享的人员
 */
export const getShareRoll = (offerId) => {
  return request({
    url: '/api/beetles-business/user-offer/get-share-designer',
    method: 'get',
    params: {offerId}
  })
}
/**
 * 获取租户底下所有用户name
 */
export const getTenantName = () => {
  return request({
    url: '/api/blade-user/get-exist-user',
    method: 'get',
  })
}
/**
 *获取订单
 */
export const selectone = (id) => {
  return request({
    url: '/api/beetles-offer/creative/detail',
    method: 'get',
    params: {
      id: id
    }
  })
}

export const getTenantDesigner = () =>{
  return request({
    url: '/api/beetles-offer/creative/get_tenant_designer',
    method: 'get',
  })
}

export const downloadCreative = (params, cb) => {
  return request({
    url: '/api/beetles-offer/creative/download-video-creative',
    method: 'get',
    params: {...params},
    timeout: 3600 * 1000,
    responseType: 'blob',
    onDownloadProgress: (event) => {
      cb(event)
    }
  })
}

export const downloadCreatives = (params, cb) => {
  return request({
    url: '/api/beetles-offer/creative/download-creatives',
    method: 'get',
    params: {...params},
    timeout: 3600 * 1000,
    responseType: 'blob',
    onDownloadProgress: (event) => {
      cb(event)
    }
  })
}

export const updateYouTube = (id, link, channelId, channelTitle) => {
  return request({
    url: '/api/beetles-offer/creative/update-youtube-info',
    method: 'put',
    params: {
      id: id,
      link: link,
      channelId: channelId,
      channelTitle: channelTitle
    }
  })
}

export const getAuditList = (createId) => {
  return request({
    url: '/api/beetles-offer/creative/getAuditList',
    method: 'get',
    params: {
      id:createId
    }
  })
}

//获取订单下的标签
export const getOfferTags = (offerId) =>{
  return request({
    url:'/api/beetles-offer/tags/model/get-by-offer',
    method:'get',
    params:{
      offerId
    }
  })
}

//保存素材的标签
export const addCreativeTags = (data) =>{
  return request({
    url:'/api/beetles-offer/creative/add-tags',
    method:'post',
    data:data
  })
}
/*导出数据*/
export const creativeExport = (data) =>{
  return request({
    responseType: 'blob',
    url: '/api/beetles-offer/creative/export-creative-excel',
    method: 'post',
    data: data
  })
}

/**获取素材在线List*/
export const getCreativeStatusDetail = (creativeId, platform, statusList, sortList)=> {
  return request(
    {
      url: '/api/beetles-offer/creative/get-creative-status-detail',
      method: 'get',
      params: {
        creativeId: creativeId,
        platform: platform,
        statusList: statusList,
        sortList: sortList
      }
    }
  )
}

export const batchUploadCreativeToTT = (data) => {
  return request(
    {
      url: '/api/beetles-offer/creative/upload-to-tt',
      method: 'post',
      data: data
    }
  )
}

export const getUploadToTTProgress = () => {
  return request(
    {
      url: '/api/beetles-offer/creative/getUploadToTTProgress',
      method: 'get',
    }
  )
}

export const getUploadToTTLatestProgress = (data) => {
  return request(
    {
      url: '/api/beetles-offer/creative/get-upload-to-tt-latest-progress',
      method: 'post',
      data: data,
    }
  )
}

export const reUploadTTCreative = (data) => {
  return request(
    {
      url: '/api/beetles-offer/creative/uploadToTTByFailReload',
      method: 'post',
      data: data,
    }
  )
}


export const uploadVideoToYoutube = (data) => {
  return request(
    {
      url: '/api/beetles-offer/creative/upload-youtube-video',
      method: 'post',
      data: data,
    }
  )
}

export const getUploadToYTProgress = (params) => {
  return request(
    {
      url: '/api/beetles-offer/creative/get-upload-youtube-status',
      method: 'get',
      params:params,
    }
  )
}
//禁用解禁按钮权限
export const getBtnVisible = () => {
  return request(
    {
      url: '/api/beetles-offer/creative/visible-button',
      method: 'get',
    }
  )
}

// 修改素材平台
export const updateCreativePlatforms = params => {
  return request(
    {
      url: '/api/beetles-offer/creative/updatePlatforms',
      method: 'post',
      params,
    }
  )
}
//记录素材下载数量
export const saveMaterialIds = data => {
  return request ({
    url: '/api/beetles-offer/creativedownloadhistory/save',
    method: 'POST',
    data
  })
}
